#include "./MessageQueue.h"

using namespace std;

void MessageQueue::enQueue(Message *msg) {
    mQ.push_back(msg);
    unique_lock<mutex> lck(mMutex);
    mCond.notify_one();
}

Message *MessageQueue::deQueue() {
    unique_lock<mutex> lck(mMutex);
    while (mQ.empty()) {
        mCond.wait(lck);
    }

    Message *msg = mQ.at(0);
    mQ.pop_front();
    return msg;
}